package com.sys.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sys.dao.CourseDao;
import com.sys.entity.Course;
import com.sys.service.CourseService;
@Service
public class CourseServiceImpl implements CourseService{
	@Resource private CourseDao courseDao;
	@Override
	public Map<String, Object> pageListCourse(String coname, String description, String createtimeStart,
			String createtimeEnd, String updatetimeStart, String updatetimeEnd, Integer del, Integer page,
			Integer limit) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("coname", coname);
		params.put("description", description);
		params.put("createtimeStart", createtimeStart);
		params.put("createtimeEnd", createtimeEnd);
		params.put("updatetimeStart", updatetimeStart);
		params.put("updatetimeEnd", updatetimeEnd);
		params.put("del", del);
		params.put("page", (page - 1) * limit);
		params.put("limit", limit);
		List<Course> course = courseDao.pageListCourse(params);
		int count = courseDao.pageListCourseCount(params);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list", course);
		map.put("count", count);
		return map;
	}

	@Override
	public int insertCourse(String coname, String description, String createtime, String updatetime, Integer del) {
		Course course = new Course();
		course.setConame(coname);
		course.setCreatetime(createtime);
		course.setDel(del);
		course.setDescription(description);
		course.setUpdatetime(updatetime);
		return courseDao.insertCourse(course);
	}

	@Override
	public int updateCourse(Integer coid, String coname, String description, String createtime, String updatetime,
			Integer del) {
		Course course = new Course();
		course.setCoid(coid);
		course.setConame(coname);
		course.setCreatetime(createtime);
		course.setDel(del);
		course.setDescription(description);
		course.setUpdatetime(updatetime);
		return courseDao.updateCourse(course);
	}

	@Override
	public int deleteCourse(Integer coid) {
		Course course = new Course();
		course.setCoid(coid);
		return courseDao.deleteCourse(course);
	}

	@Override
	public int getAllTeacherCount(Integer tid) {
		return courseDao.getAllTeacherCount(tid);
	}

	@Override
	public List<Course> getCourseListByCid(Integer cid) {
		return courseDao.getCourseListByCid(cid);
	}

	@Override
	public List<Course> tidClassCourseList(Integer cid) {
		return courseDao.tidClassCourseList(cid);
	}

	@Override
	public List<Course> getAllclassFormtwoConame() {
		return courseDao.getAllclassFormtwoConame();
	}

}
